package com;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * @author :Mr.zhou
 * @description: TODO edit class Description
 * @create date: 2023/8/27 14:47
 */
public class JsonTest {
    public static void main(String[] args) {
        String text=getStringArr();
        JSONObject jsonObject;
        String jsonText;
        JSONArray jsonArray=JSONObject.parseArray(text);
        for (int i = 0; i < jsonArray.size(); i++) {
            jsonText=  jsonArray.get(i).toString();
            jsonObject=JSONObject.parseObject(jsonText);
            System.out.println("name ="+jsonObject .get("name"));
        }
    }

    public static String getStringArr(){

        return "[\n" +
                "      {\n" +
                "        \"id\": 2,\n" +
                "        \"name\": \"张三\",\n" +
                "        \"sex\": 1,\n" +
                "        \"userSign\": \"没有签名\",\n" +
                "        \"createUser\": null,\n" +
                "        \"createTime\": \"2023-03-31T23:38:54.000+00:00\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 3,\n" +
                "        \"name\": \"彭璇\",\n" +
                "        \"sex\": 1,\n" +
                "        \"userSign\": \"啊登高望远\",\n" +
                "        \"createUser\": null,\n" +
                "        \"createTime\": \"2023-03-31T23:38:54.000+00:00\"\n" +
                "      },\n" +
                "      {\n" +
                "        \"id\": 4,\n" +
                "        \"name\": \"张大伟\",\n" +
                "        \"sex\": 1,\n" +
                "        \"userSign\": \"啊啪，快乐没了\",\n" +
                "        \"createUser\": null,\n" +
                "        \"createTime\": \"2023-03-31T23:38:54.000+00:00\"\n" +
                "      }\n" +
                "    ]";
    }
}
